package com.abe.mvp.presenter;

import com.abe.mvp.contact.WebServerContact;
import com.abe.mvp.contact.WebServerContact.Model.IWebServerBack;
import com.abe.mvp.model.WebServerModelImp;
import com.abe.mvp.model.bean.http.UserBean;

public class HttpScanLoginPresenter implements
		WebServerContact.ScanLoginPresenter {

	private WebServerContact.Model mModel;
	private WebServerContact.ScanLoginView mView;

	public HttpScanLoginPresenter(WebServerContact.ScanLoginView mView) {
		this.mView = mView;
		this.mModel = new WebServerModelImp();
	}

	@Override
	public void getScanLogin(String num) {
		mModel.getScanLoginUserInfo(num, new IWebServerBack() {
			@Override
			public void onResult(int code, Object data, String errorMSG) {
				if (code == 1) {
					mView.onScanLoginSuccess((UserBean) data);
				} else {
					mView.onRequestFail(errorMSG);
				}
			}

			@Override
			public void onFinish() {
				mView.onFinish(WebServerContact.TYPE_SCAN);
			}
		});
	}

}
